<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;

use Encore\Admin\Widgets\Box;

//use Encore\Admin\Widgets\Chart\Bar;
//use Encore\Admin\Widgets\Chart\Doughnut;
//use Encore\Admin\Widgets\Chart\Line;
//use Encore\Admin\Widgets\Chart\Pie;
//use Encore\Admin\Widgets\Chart\PolarArea;
//use Encore\Admin\Widgets\Chart\Radar;
use Encore\Admin\Widgets\Collapse;
use Encore\Admin\Widgets\InfoBox;
use Encore\Admin\Widgets\Tab;
use Encore\Admin\Widgets\Table;
use Encore\Admin\Widgets\Form;

class HomeController extends Controller
{
    public function index()
    {
        return Admin::content(function (Content $content) {

            $content->header('Dashboard');
            $content->description('Description...');

            $content->row(Dashboard::title());

            $content->row(function (Row $row) {

                $row->column(4, function (Column $column) {
                    $column->append(Dashboard::environment());
                });

                $row->column(4, function (Column $column) {
                    $column->append(Dashboard::extensions());
                });

                $row->column(4, function (Column $column) {
                    $column->append(Dashboard::dependencies());
                });
            });

            $content->row(function ($row) {
                $row->column(3, new InfoBox('New Users', 'users', 'aqua', '/admin/users', '1024'));
                $row->column(3, new InfoBox('New Orders', 'shopping-cart', 'green', '/admin/orders', '150%'));
                $row->column(3, new InfoBox('Articles', 'book', 'yellow', '/admin/articles', '2786'));
                $row->column(3, new InfoBox('Documents', 'file', 'red', '/admin/files', '698726'));
            });

//            $content->row(function (Row $row) {
//
//                $row->column(6, function (Column $column) {
//
//                    $tab = new Tab();
//
//                    $pie = new Pie([
//                        ['Stracke Ltd', 450], ['Halvorson PLC', 650], ['Dicki-Braun', 250], ['Russel-Blanda', 300],
//                        ['Emmerich-O\'Keefe', 400], ['Bauch Inc', 200], ['Leannon and Sons', 250], ['Gibson LLC', 250],
//                    ]);
//
//                    $tab->add('Pie', $pie);
//                    $tab->add('Table', new Table());
//                    $tab->add('Text', 'blablablabla....');
//
//                    $tab->dropDown([['Orders', '/admin/orders'], ['administrators', '/admin/administrators']]);
//                    $tab->title('Tabs');
//
//                    $column->append($tab);
//
//                    $collapse = new Collapse();
//
//                    $bar = new Bar(
//                        ["January", "February", "March", "April", "May", "June", "July"],
//                        [
//                            ['First', [40,56,67,23,10,45,78]],
//                            ['Second', [93,23,12,23,75,21,88]],
//                            ['Third', [33,82,34,56,87,12,56]],
//                            ['Forth', [34,25,67,12,48,91,16]],
//                        ]
//                    );
//                    $collapse->add('Bar', $bar);
//                    $collapse->add('Orders', new Table());
//                    $column->append($collapse);
//
//                    $doughnut = new Doughnut([
//                        ['Chrome', 700],
//                        ['IE', 500],
//                        ['FireFox', 400],
//                        ['Safari', 600],
//                        ['Opera', 300],
//                        ['Navigator', 100],
//                    ]);
//                    $column->append((new Box('Doughnut', $doughnut))->removable()->collapsable()->style('info'));
//                });
//
//                $row->column(6, function (Column $column) {
//
//                    $column->append(new Box('Radar', new Radar()));
//
//                    $polarArea = new PolarArea([
//                        ['Red', 300],
//                        ['Blue', 450],
//                        ['Green', 700],
//                        ['Yellow', 280],
//                        ['Black', 425],
//                        ['Gray', 1000],
//                    ]);
//                    $column->append((new Box('Polar Area', $polarArea))->removable()->collapsable());
//
//                    $column->append((new Box('Line', new Line()))->removable()->collapsable()->style('danger'));
//                });
//
//            });

            $headers = ['Id', 'Email', 'Name', 'Company', 'Last Login', 'Status'];
            $rows = [
                [1, 'labore21@yahoo.com', 'Ms. Clotilde Gibson', 'Goodwin-Watsica', '1997-08-13 13:59:21', 'open'],
                [2, 'omnis.in@hotmail.com', 'Allie Kuhic', 'Murphy, Koepp and Morar', '1988-07-19 03:19:08', 'blocked'],
                [3, 'quia65@hotmail.com', 'Prof. Drew Heller', 'Kihn LLC', '1978-06-19 11:12:57', 'blocked'],
                [4, 'xet@yahoo.com', 'William Koss', 'Becker-Raynor', '1988-09-07 23:57:45', 'open'],
                [5, 'ipsa.aut@gmail.com', 'Ms. Antonietta Kozey Jr.', 'Braun Ltd', '2013-10-16 10:00:01', 'open'],
            ];

            $content->row((new Box('Table', new Table($headers, $rows)))->style('info')->solid());


            $content->row(function ($row) {
                $form = new Form();

                $form->action('example');

                $form->email('email')->default('qwe@aweq.com');
                $form->password('password');
                $form->text('name', '输入框');
                $form->url('url');
                $form->color('color');
                $form->map('lat', 'lng');
                $form->date('date');
                $form->json('val');
                $form->dateRange('created_at', 'updated_at');

                $row->column(6, $form);

                $collapse = new Collapse();

                $collapse->add('Bar', 'xxxxx');
                $collapse->add('Orders', new Table());

                $row->column(6, $collapse);


            });
        });
    }
}
